﻿using ScriptCs.SpeakR.ScriptPack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeighSystem.Class
{
    public  class SpeechHelper: IDisposable
    {
        bool _disposed; //https://blog.csdn.net/Wake34/article/details/52410736
        public SpeakR speaker;
        public SpeechHelper()
        {
            speaker = new SpeakR();
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        //这里的参数表示示是否需要释放那些实现IDisposable接口的托管对象
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed) return; //如果已经被回收，就中断执行
            if (disposing)
            {
                //TODO:释放那些实现IDisposable接口的托管对象
            }
            //TODO:释放非托管资源，设置对象为null
            _disposed = true;
        }
        public bool  StartSpeaker(string text)
        {
            try
            {
                speaker.Speak(text);
                return true;
            }
            catch (Exception)
            {

                return false;
            }
       

        }
           
    }
}
